import { get, post } from '@/utils/request'

// 查询资讯分类数据
export const getNewsCategory = () => get('/category/findAll')

// 根据id删除对应分类
export const deleteNewsCategory = (categoryId) =>
  get(`/category/deleteById?id=${categoryId}`)

// 新增或更新分类
export const addOrEditNewsCategory = (categoryData) =>
  post('/category/saveOrUpdate', categoryData)

// 批量删除新闻分类
export const batchDeleteNewsCategory = (ids) =>
  post('/category/batchDelete?ids=' + ids)

// 获取新闻分页信息
export const getNewsPagination = (pagination) =>
  get(
    '/article/pageQuery?page=' +
      pagination.page +
      '&pageSize=' +
      pagination.pageSize +
      '&title=' +
      pagination.title
  )

// 根据id查询新闻
export const getNewsById = (id) => get('/article/findById?id=' + id)

// 根据id删除新闻
export const removeNews = (newsId) => get('/article/deleteById?id=' + newsId)

// 添加新闻
export const addNews = (newsData) => post('/article/saveOrUpdate', newsData)
